import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import { ElNotification } from 'element-plus'
import { h } from 'vue'

const app = createApp(App)

app.use(createPinia())
app.use(router)
app.use(ElementPlus)

window.addEventListener('ws-notify', (e) => {
  console.log('[ws-notify事件] 收到', e.detail);
  ElNotification({
    title: e.detail.title,
    message: h('i', { style: 'color: teal' }, e.detail.content),
    duration: 3000,
    onClick: () => {
      router.push({ name: 'Chat', params: { userId: e.detail.userId } })
    }
  })
})

app.mount('#app')
